from django.template import Library
from django.conf import settings

import pytz

from base.utils import localtime_from_utc, utc_from_localtime

register = Library()

def localdatetime(value, timezone):
    return localtime_for_timezone(value, timezone)

def localdate(datetime):
    datetime = localtime_from_utc(datetime)
    return datetime.strftime("%d/ %b/ %Y")

def localdate_link(datetime):
    datetime = localtime_from_utc(datetime)
    return datetime.strftime("%Y/%m/%d")

def localtime(datetime):
    datetime = localtime_from_utc(datetime)
    return datetime.strftime("%H:%M:%S")

register.filter("localdatetime", localdatetime)
register.filter("localdate", localdate)
register.filter("localdate_link", localdate_link)
register.filter("localtime", localtime)